# Maintainer: Joseph Benden <joe@benden.us>

pkgname=rsync2
pkgver=3.1.3dev_msys2.7.0_r3
pkgrel=0
pkgdesc="A file transfer program to keep remote files in sync"
arch=('i686' 'x86_64')
url="https://github.com/jbenden/rsync"
groups=('net-utils')
license=('GPL3')
depends=('libiconv')
makedepends=('msys2-w32api-headers' 'perl' 'yodl')
conflicts=('rsync')
provides=('rsync')
pkgsname=rsync
pkgsver="3.1.3dev-msys2.7.0-r3"
source=("https://codeload.github.com/jbenden/rsync/tar.gz/v3.1.3dev-msys2.7.0-r3"
        "ssh-6-option.patch")
sha256sums=('cbb854ede248bf62f8fc6eb43553dd7d6b30909f8dc290a1bc329e7fe6e30bc0'
            'ea88046d8935e7a597cca7379d21edffefa520792d896bd7ce663b4cdc0f2069')

prepare() {
  cd "${srcdir}/${pkgsname}-${pkgsver}"

  patch -p1 -i ${srcdir}/ssh-6-option.patch

  autoreconf -fiv
}

build() {
  cd "${srcdir}/${pkgsname}-${pkgsver}"
  env CFLAGS="$CFLAGS -O2 -std=c99 -Wall -Wextra -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-parameter -Wno-deprecated-declarations -DNDEBUG" \
      LDFLAGS="$LDFLAGS -Wl,--enable-auto-image-base" \
        ./configure \
          --build=${CHOST} \
          --prefix=/usr \
          --with-w32api-include-path=/usr/include/w32api \
          --with-protected-args \
          --with-included-popt \
          --with-included-zlib \
          --disable-debug \
          --enable-iconv
  
  make reconfigure
  make man all
}

check() {
  cd "${srcdir}/${pkgsname}-${pkgsver}"
  make test || make test
}

package() {
  cd "${srcdir}/${pkgsname}-${pkgsver}"
  make DESTDIR="${pkgdir}" install
  install -Dm755 support/rrsync "${pkgdir}/usr/lib/rsync/rrsync"
}
